﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SRB.Tg.Operate
{
    public class Common
    {
        /// <summary>
        /// 获取文件夹下线路文件夹
        /// </summary>
        /// <param name="dirPath">线路所在文件夹的相对路径</param>
        /// <returns></returns>
        public static List<string> GetLineDir(string dirPath)
        {
            List<string> dirs = new List<string>();
            DirectoryInfo path = new DirectoryInfo(dirPath);
            foreach (DirectoryInfo dir in path.GetDirectories())//
            {
                string dirpath = dir.FullName;
                dirs.Add(dirpath);
            }
            return dirs;
        }

        /// <summary>
        ///获取当前文件夹下的dwg文件
        /// </summary>
        /// <param name="dirPath"></param>
        /// <returns></returns>
        public static List<string> GetDwgFiles(string dirPath)
        {
            List<string> files = new List<string>();
            DirectoryInfo path = new DirectoryInfo(dirPath);
            foreach (FileInfo file in path.GetFiles("*.dwg", SearchOption.TopDirectoryOnly))//
            {
                string filepath = file.FullName;
                files.Add(filepath);
            }
            return files;
        }


        /// <summary>
        ///获取当前文件夹及子文件夹下的dwg文件
        /// </summary>
        /// <param name="dirPath"></param>
        /// <returns></returns>
        public static List<string> GetAllDwgFiles(string dirPath)
        {
            List<string> files = new List<string>();
            DirectoryInfo path = new DirectoryInfo(dirPath);
            foreach (FileInfo file in path.GetFiles("*.dwg", SearchOption.AllDirectories))//
            {
                string filepath = file.FullName;
                files.Add(filepath);
            }
            return files;
        }
        /// <summary>
        /// 角度转弧度
        /// </summary>
        /// <param name="degrees"></param>
        /// <returns></returns>
        public static double ConvertDegreesToRadians(double degrees)
        {
            double radians = (Math.PI / 180) * degrees;
            return (radians);
        }
        /// <summary>
        /// 弧度转角度
        /// </summary>
        /// <param name="radians"></param>
        /// <returns></returns>
        public static double ConvertRadiansToDegrees(double radians)
        {
            double degrees  = 180* radians/ Math.PI ;
            return (degrees);
        }

    }

}
